window.onload=function(){
    axios.post('https://ty.php800.cn/api/member/search.php','',{
        headers:{
            TOKEN:localStorage.getItem('token'),
            SAT:'1234567'
        }
    }).then((res)=> {
        let sorter=document.querySelector('.sorter');
        let left=document.createElement('li'),
        right=document.createElement('li');
        left.innerHTML='&#xebc8;'
        right.innerHTML='&#xe636;'
        sorter.appendChild(left);
        for(let i=0,q=1;i<i<res.data.member.length;i++,q++){
            let div=document.createElement('div'),
                li=document.createElement('li');
                div.classList.add('div_li')
            for(let j=0;j<12;i++,j++){
                let {authority,email,gender,id,nickname,phone,registrationtime,roleid}=res.data.member[i]
                let ul=document.createElement('ul')
                ul.classList.add('message')
                let date=new Date(parseInt(registrationtime))
                date=date.getFullYear()+'年'+addzero(date.getMonth()+1)+'月'+addzero(date.getDate())+'日&nbsp;&nbsp;&nbsp;&nbsp;'+addzero(date.getHours())+':'+addzero(date.getMinutes())+":"+addzero(date.getSeconds())
                ul.innerHTML=`
                    <li>${id}</li>
                    <li>${nickname===''?'这个人没有昵称':nickname}</li>
                    <li>${gender==='0'?'女':'男'}</li>
                    <li>${roleid}</li>
                    <li>${authority==0?'超级管理员':authority==1?'普通管理员':authority==9?'注册会员':'不明'}</li>
                    <li>${date}</li>
                    <li>${phone}</li>
                    <li>${email}</li>
                    <li><a href='./alter_message.html' class='alter_message'>修改信息</a>|<a href='./repassword.html' class='repassword'>修改密码</a></li>
                `
                ul.querySelector('.repassword').onclick=function(){
                    localStorage.setItem('thisPeopleId',id)
                }
                let alter_message=JSON.stringify(res.data.member[i])
                ul.querySelector('.alter_message').onclick=function(){
                    localStorage.setItem('alter_message',alter_message)
                }
                div.appendChild(ul)
                if(i>=res.data.member.length-1)break;
            }
            document.querySelector('.bigdiv').appendChild(div)
            li.innerHTML=q
            sorter.appendChild(li)
            if(i>=res.data.member.length-1)break;
        }
        sorter.appendChild(right);
        let sorterLi=document.querySelectorAll('.sorter li'),
        bigDiv=document.querySelector('.bigdiv'),
        excursion=bigDiv.querySelector('div').offsetWidth||0,
        count=0;
        for(i=1;i<sorterLi.length-1;i++){
            sorterLi[i].onclick=function(){
                count=this.innerHTML-1
                bigDiv.style.left=-excursion*count+'px'
            }
        }
        sorterLi[0].onclick=function(){
            count--
            count=count<=0?0:count
            bigDiv.style.left=-excursion*count+'px'
        }
        sorterLi[sorterLi.length-1].onclick=function(){
            count++
            count=count>=i-2?i-2:count
            bigDiv.style.left=-excursion*count+'px'
        }
    });
}
function addzero(date){
    return date<10?'0'+date:date
}